package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.TravelCollection;
import cn.wolfcode.trip.base.mapper.TravelCollectionMapper;
import cn.wolfcode.trip.base.query.TravelCollectionQuery;
import cn.wolfcode.trip.base.service.ITravelCollectionService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class TravelCollectionServiceImpl implements ITravelCollectionService {

    @Autowired
    private TravelCollectionMapper collectionMapper;

    @Override
    public void save(Long userId,Long travelId) {

        collectionMapper.insert(userId,travelId,new Date());
    }

    @Override
    public TravelCollection get(Long userId, Long travelId) {
        return collectionMapper.get(userId,travelId);
    }

    @Override
    public void delete(Long userId, Long travelId) {
        collectionMapper.delete(userId,travelId);
    }

    @Override
    public PageInfo<TravelCollection> list(TravelCollectionQuery qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        List<TravelCollection> list = collectionMapper.selectAll();
        return new PageInfo<>(list);
    }


}
